package com.yzw;

import com.yzw.decorator.CD;
import com.yzw.decorator.Computer;
import com.yzw.decorator.Disk;
import com.yzw.decorator.Monitor;

/**
 * @author yw
 * @date 2024/5/27
 * 装饰器模式 主要是不想改变原有代码，对逻辑进行拓展增强
 */
public class DecoratorTestMain {
    public static void main(String[] args) {
        Computer computer = new Computer();
        // 在子类中对原有方法进行了加强
        computer = new Disk(computer);
        computer = new Monitor(computer);
        computer = new CD(computer);
        computer = new CD(computer);
        System.out.println("You're getting a " + computer.description() + '.');
    }
}
